﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace shenkong.Models
{
    public partial class dormitoryContext : DbContext
    {
        public dormitoryContext()
        {
        }

        public dormitoryContext(DbContextOptions<dormitoryContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Area> Areas { get; set; } = null!;
        public virtual DbSet<Building> Buildings { get; set; } = null!;
        public virtual DbSet<ChangeDorm> ChangeDorms { get; set; } = null!;
        public virtual DbSet<Dep> Deps { get; set; } = null!;
        public virtual DbSet<DepartMent> DepartMents { get; set; } = null!;
        public virtual DbSet<Dorm> Dorms { get; set; } = null!;
        public virtual DbSet<Electricity> Electricities { get; set; } = null!;
        public virtual DbSet<Manager> Managers { get; set; } = null!;
        public virtual DbSet<Notice> Notices { get; set; } = null!;
        public virtual DbSet<Photo> Photos { get; set; } = null!;
        public virtual DbSet<Price> Prices { get; set; } = null!;
        public virtual DbSet<QuitDorm> QuitDorms { get; set; } = null!;
        public virtual DbSet<RepairRecord> RepairRecords { get; set; } = null!;
        public virtual DbSet<Spe> Spes { get; set; } = null!;
        public virtual DbSet<Speciality> Specialities { get; set; } = null!;
        public virtual DbSet<Student> Students { get; set; } = null!;
        public virtual DbSet<SysEffect> SysEffects { get; set; } = null!;
        public virtual DbSet<VisitRecord> VisitRecords { get; set; } = null!;
        public virtual DbSet<Water> Water { get; set; } = null!;
        public virtual DbSet<Weiji> Weijis { get; set; } = null!;
        public virtual DbSet<WorkList> WorkLists { get; set; } = null!;
        public virtual DbSet<Worker> Workers { get; set; } = null!;

//        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//        {
//            if (!optionsBuilder.IsConfigured)
//            {
//#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
//                optionsBuilder.UseSqlServer("Server=172.17.55.130;Database=dormitory;User ID=sa;Password=sa;MultipleActiveResultSets=true;");
//            }
//        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Area>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("area");

                entity.Property(e => e.AreaId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("area_id");

                entity.Property(e => e.AreaName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("area_name");
            });

            modelBuilder.Entity<Building>(entity =>
            {
                entity.ToTable("building");

                entity.Property(e => e.BuildingId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("building_id");

                entity.Property(e => e.Beizhu)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("beizhu");

                entity.Property(e => e.BuidingContain).HasColumnName("buiding_contain");

                entity.Property(e => e.BuildingName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("building_name");

                entity.Property(e => e.Lived).HasColumnName("lived");

                entity.Property(e => e.RoomNum).HasColumnName("room_num");

                entity.Property(e => e.SexClass)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("sexClass");
            });

            modelBuilder.Entity<ChangeDorm>(entity =>
            {
                entity.HasKey(e => e.ChangeId);

                entity.ToTable("changeDorm");

                entity.Property(e => e.ChangeId).HasColumnName("change_id");

                entity.Property(e => e.ConfirmMaterial)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("confirm_material");

                entity.Property(e => e.DealAdm)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("deal_adm");

                entity.Property(e => e.DormChange)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_change");

                entity.Property(e => e.DormNow)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_now");

                entity.Property(e => e.Opinion)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("opinion");

                entity.Property(e => e.Reason)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("reason");

                entity.Property(e => e.ReplyDate)
                    .HasColumnType("date")
                    .HasColumnName("reply_date");

                entity.Property(e => e.Status)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("status");

                entity.Property(e => e.StuId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("stu_id");

                entity.Property(e => e.StuName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("stu_name");
            });

            modelBuilder.Entity<Dep>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("dep");

                entity.Property(e => e.Department)
                    .HasMaxLength(10)
                    .HasColumnName("department")
                    .IsFixedLength();
            });

            modelBuilder.Entity<DepartMent>(entity =>
            {
                entity.HasKey(e => e.DepId);

                entity.ToTable("DepartMent");

                entity.Property(e => e.DepId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dep_id");

                entity.Property(e => e.DepName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dep_name");
            });

            modelBuilder.Entity<Dorm>(entity =>
            {
                entity.ToTable("dorm");

                entity.Property(e => e.DormId)
                    .HasMaxLength(5)
                    .HasColumnName("dorm_id")
                    .IsFixedLength();

                entity.Property(e => e.BuilidingName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("builiding_name");

                entity.Property(e => e.DormClass)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dormClass");

                entity.Property(e => e.DormContain).HasColumnName("dorm_contain");

                entity.Property(e => e.Liver).HasColumnName("liver");
            });

            modelBuilder.Entity<Electricity>(entity =>
            {
                entity.HasKey(e => e.EleId)
                    .HasName("PK_electricity_1");

                entity.ToTable("electricity");

                entity.Property(e => e.EleId).HasColumnName("ele_id");

                entity.Property(e => e.DormId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_id");

                entity.Property(e => e.ElectricityDate)
                    .HasColumnType("datetime")
                    .HasColumnName("electricity_date");

                entity.Property(e => e.ElectricityPrice)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("electricity_price")
                    .HasDefaultValueSql("((0.55))");

                entity.Property(e => e.ElectricityQuota)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("electricity_quota");

                entity.Property(e => e.ElectricitySpend).HasColumnName("electricity_spend");

                entity.Property(e => e.SpendQuota)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("spend_quota");
            });

            modelBuilder.Entity<Manager>(entity =>
            {
                entity.HasKey(e => e.Name)
                    .HasName("PK__manager__5A6073FC581F8879");

                entity.ToTable("manager");

                entity.HasIndex(e => e.Name, "IX_manager");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("name");

                entity.Property(e => e.Email)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("email");

                entity.Property(e => e.Keys).HasColumnName("keys");

                entity.Property(e => e.Pwd)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("pwd");
            });

            modelBuilder.Entity<Notice>(entity =>
            {
                entity.ToTable("notice");

                entity.Property(e => e.NoticeId).HasColumnName("notice_id");

                entity.Property(e => e.NoticeContent)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("notice_content");

                entity.Property(e => e.NoticeDate)
                    .HasColumnType("date")
                    .HasColumnName("notice_date");

                entity.Property(e => e.NoticeStatus)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("notice_status");

                entity.Property(e => e.NoticeTitle)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("notice_title");
            });

            modelBuilder.Entity<Photo>(entity =>
            {
                entity.HasKey(e => e.StuId);

                entity.ToTable("photo");

                entity.Property(e => e.StuId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("stu_id");

                entity.Property(e => e.Url)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("url");
            });

            modelBuilder.Entity<Price>(entity =>
            {
                entity.ToTable("price");

                entity.Property(e => e.PriceId)
                    .ValueGeneratedNever()
                    .HasColumnName("price_id");

                entity.Property(e => e.ElePrice)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("ele_price");

                entity.Property(e => e.WaterPrice)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("water_price");
            });

            modelBuilder.Entity<QuitDorm>(entity =>
            {
                entity.HasKey(e => e.QuitId);

                entity.ToTable("QuitDorm");

                entity.Property(e => e.QuitId).HasColumnName("quit_id");

                entity.Property(e => e.DealAdm)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("deal_adm");

                entity.Property(e => e.DormId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_id");

                entity.Property(e => e.LeaderConfirm)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("leader_confirm");

                entity.Property(e => e.Opinion)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasColumnName("opinion");

                entity.Property(e => e.ParentsConfirm)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("parents_confirm");

                entity.Property(e => e.Reason)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("reason");

                entity.Property(e => e.ReplyClass)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("reply_class");

                entity.Property(e => e.ReplyDate)
                    .HasColumnType("date")
                    .HasColumnName("reply_date");

                entity.Property(e => e.Status)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("status");

                entity.Property(e => e.StuId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("stu_id");

                entity.Property(e => e.StuName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("stu_name");
            });

            modelBuilder.Entity<RepairRecord>(entity =>
            {
                entity.HasKey(e => e.RepairId)
                    .HasName("PK__repair_r__98DC7A28715A24BF");

                entity.ToTable("repair_record");

                entity.Property(e => e.RepairId).HasColumnName("repair_id");

                entity.Property(e => e.ApplyDate)
                    .HasColumnType("date")
                    .HasColumnName("apply_date");

                entity.Property(e => e.BuildName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("buildName");

                entity.Property(e => e.DormId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_id");

                entity.Property(e => e.FreeTime)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("free_time");

                entity.Property(e => e.RepairClass)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("repair_class");

                entity.Property(e => e.RepairProblem)
                    .HasMaxLength(100)
                    .HasColumnName("repair_problem");

                entity.Property(e => e.Replyer)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("replyer");

                entity.Property(e => e.Tel)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("tel");

                entity.Property(e => e.WorkId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("work_id");

                entity.Property(e => e.Zhuangtai)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("zhuangtai");
            });

            modelBuilder.Entity<Spe>(entity =>
            {
                entity.ToTable("spe");

                entity.Property(e => e.SpeId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("spe_id");

                entity.Property(e => e.DepId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dep_id");

                entity.Property(e => e.SpeName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("spe_name");
            });

            modelBuilder.Entity<Speciality>(entity =>
            {
                entity.HasNoKey();

                entity.ToView("speciality");

                entity.Property(e => e.Speciality1)
                    .HasMaxLength(10)
                    .HasColumnName("speciality");
            });

            modelBuilder.Entity<Student>(entity =>
            {
                entity.ToTable("student");

                entity.Property(e => e.StudentId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("student_id");

                entity.Property(e => e.BedId).HasColumnName("bed_id");

                entity.Property(e => e.Department)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("department");

                entity.Property(e => e.DormId)
                    .HasMaxLength(5)
                    .HasColumnName("dorm_id")
                    .IsFixedLength();

                entity.Property(e => e.Photo)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("photo");

                entity.Property(e => e.Sex)
                    .HasMaxLength(2)
                    .IsUnicode(false)
                    .HasColumnName("sex")
                    .HasDefaultValueSql("('男')")
                    .IsFixedLength();

                entity.Property(e => e.Speciality)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("speciality");

                entity.Property(e => e.Startday)
                    .HasColumnType("date")
                    .HasColumnName("startday");

                entity.Property(e => e.StudentName)
                    .HasMaxLength(20)
                    .HasColumnName("student_name");

                entity.Property(e => e.Telephone)
                    .HasMaxLength(11)
                    .IsUnicode(false)
                    .HasColumnName("telephone")
                    .IsFixedLength();
            });

            modelBuilder.Entity<SysEffect>(entity =>
            {
                entity.HasKey(e => e.EffectId)
                    .HasName("PK__sys_effe__AC79D23B6A639378");

                entity.ToTable("sys_effect");

                entity.Property(e => e.EffectId).HasColumnName("effect_id");

                entity.Property(e => e.Adm)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("adm");

                entity.Property(e => e.Effect)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("effect");

                entity.Property(e => e.EffectTime)
                    .HasColumnType("datetime")
                    .HasColumnName("effect_time");

                entity.Property(e => e.Info)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("info");

                entity.HasOne(d => d.AdmNavigation)
                    .WithMany(p => p.SysEffects)
                    .HasForeignKey(d => d.Adm)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_sys_effect_manager");
            });

            modelBuilder.Entity<VisitRecord>(entity =>
            {
                entity.ToTable("visit_record");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.BuildingName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("building_name");

                entity.Property(e => e.EnterTime)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("enter_time");

                entity.Property(e => e.LeaveTime)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("leave_time");

                entity.Property(e => e.VisitReason)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("visit_reason");

                entity.Property(e => e.VisitRelation)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("visit_relation");

                entity.Property(e => e.VisitTime)
                    .HasColumnType("date")
                    .HasColumnName("visit_time");

                entity.Property(e => e.Visitor)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("visitor");
            });

            modelBuilder.Entity<Water>(entity =>
            {
                entity.ToTable("water");

                entity.Property(e => e.WaterId).HasColumnName("water_id");

                entity.Property(e => e.DormId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_id");

                entity.Property(e => e.SpenQuota)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("spen_quota");

                entity.Property(e => e.WaterDate)
                    .HasColumnType("datetime")
                    .HasColumnName("water_date");

                entity.Property(e => e.WaterPrice)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("water_price")
                    .HasDefaultValueSql("((4))");

                entity.Property(e => e.WaterQuota)
                    .HasColumnType("decimal(18, 2)")
                    .HasColumnName("water_quota");

                entity.Property(e => e.WaterSpend).HasColumnName("water_spend");
            });

            modelBuilder.Entity<Weiji>(entity =>
            {
                entity.HasKey(e => e.RecordId);

                entity.ToTable("weiji");

                entity.Property(e => e.RecordId).HasColumnName("record_id");

                entity.Property(e => e.Advice)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("advice");

                entity.Property(e => e.DormId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("dorm_id");

                entity.Property(e => e.RecordContent)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasColumnName("record_content");

                entity.Property(e => e.RecordDate)
                    .HasColumnType("datetime")
                    .HasColumnName("record_date");

                entity.Property(e => e.Recorder)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("recorder");
            });

            modelBuilder.Entity<WorkList>(entity =>
            {
                entity.HasKey(e => e.ListId);

                entity.ToTable("workList");

                entity.Property(e => e.ListId).HasColumnName("list_id");

                entity.Property(e => e.BuildId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("build_id");

                entity.Property(e => e.BuildName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("build_name");

                entity.Property(e => e.Friday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Monday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.NFriday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nFriday");

                entity.Property(e => e.NMonday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nMonday");

                entity.Property(e => e.NSaturday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nSaturday");

                entity.Property(e => e.NSunday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nSunday");

                entity.Property(e => e.NThursday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nThursday");

                entity.Property(e => e.NTuesday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nTuesday");

                entity.Property(e => e.NWednesday)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("nWednesday");

                entity.Property(e => e.Saturday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Sunday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Thursday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Tuesday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Wednesday)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Week)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("week");
            });

            modelBuilder.Entity<Worker>(entity =>
            {
                entity.HasKey(e => e.WorkId)
                    .HasName("PK__worker__569F8007EF21F7FC");

                entity.ToTable("worker");

                entity.Property(e => e.WorkId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("work_id");

                entity.Property(e => e.WorkerName)
                    .HasMaxLength(10)
                    .HasColumnName("worker_name");

                entity.Property(e => e.WorkerProfession)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("worker_profession");

                entity.Property(e => e.WorkerSex)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("worker_sex");

                entity.Property(e => e.WorkerTelephone)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("worker_telephone");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
